package com.kd.eb.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kd.eb.mapper.EbNewsMapper;
import com.kd.eb.mapper.EbProductMapper;
import com.kd.eb.model.EbNews;
import org.springframework.aop.interceptor.ExposeBeanNameAdvisors;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class IndexService {
    @Resource
    private EbProductMapper ebProductMapper;
    @Resource
    private EbNewsMapper ebNewsMapper;

    public Map<String, Page> index(int page,int pageSize){
        System.out.println("进入index的service方法......");
        Map<String, Page> result = new HashMap<>();
        //TODO 1.
        Page page1 = new Page(page, pageSize);
        Page productPage = ebProductMapper.selectPage(page1,null);
        System.out.println("已查询商品数据");

        //TODO 2.
        page1 = new Page(1,8);
        Page newsPage = ebNewsMapper.selectPage(page1, new QueryWrapper<EbNews>()
                .orderByDesc("en_create_time"));

        result.put("productPage",productPage);
        result.put("newsPage",newsPage);
        return result;

    }
}
